Option Strict Off
Option Explicit On
Imports Microsoft.VisualBasic.PowerPacks
Namespace BMLERP
	Friend Class frmACR100
		Inherits System.Windows.Forms.Form
		Dim OldCMCNO As String
		Private Sub cboCMCID_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As AxMSDataListLib.DDataComboEvents_ClickEvent) Handles cboCMCID.ClickEvent
			If eventArgs.area = 2 Then
				txtCMCID.Text = cboCMCID.BoundText
				txtCNONM.Text = cboCMCID.CtlText
				cboCMCID.Visible = False
				txtCMTYP.Focus()
			End If
		End Sub

		Private Sub cboCMCNO_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As AxMSDataListLib.DDataComboEvents_ClickEvent) Handles cboCMCNO.ClickEvent
			If eventArgs.area = 2 Then
				ISEDITING = False
				WriteToScreen()
				ButtonStatus()
			End If
		End Sub

		Private Sub cboCMPTC_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As AxMSDataListLib.DDataComboEvents_ClickEvent) Handles cboCMPTC.ClickEvent
			If eventArgs.area = 2 Then
				txtCMPTC.Text = cboCMPTC.BoundText
				txtPTDSC.Text = cboCMPTC.CtlText
				cboCMPTC.Visible = False
				txtCMSTN.Focus()
			End If
		End Sub

		Private Sub cboCMSNO_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As AxMSDataListLib.DDataComboEvents_ClickEvent) Handles cboCMSNO.ClickEvent
			If eventArgs.area = 2 Then
				txtCMSNO.Text = cboCMSNO.BoundText
				txtMMNME.Text = cboCMSNO.CtlText
				cboCMSNO.Visible = False
			End If
		End Sub

		Private Sub cboCMTYP_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As AxMSDataListLib.DDataComboEvents_ClickEvent) Handles cboCMTYP.ClickEvent
			If eventArgs.area = 2 Then
				txtCMTYP.Text = cboCMTYP.BoundText
				txtCTDSC.Text = cboCMTYP.CtlText
				cboCMTYP.Visible = False
				txtCMNME.Focus()
			End If
		End Sub

		Private Sub cboCMVAT_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As AxMSDataListLib.DDataComboEvents_ClickEvent) Handles cboCMVAT.ClickEvent
			If eventArgs.area = 2 Then
				txtCMVAT.Text = cboCMVAT.BoundText
				txtVTDSC.Text = cboCMVAT.CtlText
				cboCMVAT.Visible = False
				txtCMCLM.Focus()
			End If
		End Sub

		Private Sub chkCMCRS_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkCMCRS.CheckStateChanged
			'txtCMPTC.SetFocus
		End Sub

		Private Sub cmdAddnew_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdAddnew.Click
			ISADDING = True
			ISEDITING = True
			WriteToScreen()
			ButtonStatus()
		End Sub

		Private Sub cmdCancel_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdCancel.Click
			ISADDING = False
			ISEDITING = False
			ButtonStatus()
		End Sub

		Private Sub cmdDelete_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdDelete.Click
			Dim Response As Object
			Response = MsgBox("Are you sure to delete this customer?", MsgBoxStyle.YesNo + MsgBoxStyle.Critical + MsgBoxStyle.DefaultButton2, "Chu y'")
			If Response = MsgBoxResult.Yes Then
				DBconn.Execute("DELETE FROM RCM where CMCNO='" & cboCMCNO.BoundText & "'")
			End If

		End Sub

		Private Sub cmdEdit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdEdit.Click
			ISEDITING = True
			WriteToScreen()
			ButtonStatus()
		End Sub

		Private Sub cmdExit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdExit.Click
			Me.Close()
		End Sub

		Private Sub cmdSave_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSave.Click
			WriteToFile()
			ISADDING = False
			ISEDITING = False
			ButtonStatus()
		End Sub

		Sub ButtonStatus()
			cmdAddnew.Enabled = Not ISEDITING
			cmdEdit.Enabled = Not ISEDITING And txtCMCNO.Text <> ""
			cmdSave.Enabled = ISEDITING	' And txtIMITN <> ""
			cmdDelete.Enabled = Not ISEDITING 'And txtIMITN <> ""
			cmdCancel.Enabled = ISEDITING
			frameACR100.Enabled = ISEDITING
			'txtIMITN.Locked = Not ISADDING ' Lock item code tru truong hop ISADDING=true
			'txtDepartment.Enabled = ISEDITING
			'cboDepartment.Visible = Not ISADDING
			'txtDepartmentID.Visible = ISADDING
		End Sub

		Sub WriteToScreen()
			Dim RecRCM As ADODB.Recordset
			If ISADDING Then
				txtCMCNO.Text = ""
				txtCMNME.Text = ""
				txtCMCTN.Text = ""
				txtCMAD1.Text = ""
				txtCMAD2.Text = ""
				txtCMCIT.Text = ""
				txtCMPSC.Text = ""
				txtCMCNT.Text = "Viet Nam"
				txtCMTEL.Text = ""
				txtCMFAX.Text = ""
				txtCMVID.Text = ""
				txtCMCID.Text = ""
				txtCNONM.Text = ""
				cboCMCID.defText = ""
				txtCMGCD.Text = ""
				txtCMSNO.Text = ""
				txtMMNME.Text = ""
				cboCMSNO.defText = ""
				txtCMCLM.Text = ""
				chkCMCRS.CheckState = System.Windows.Forms.CheckState.Unchecked
				txtCMPTC.Text = ""
				txtPTDSC.Text = ""
				txtCMTYP.Text = ""
				txtCTDSC.Text = ""
				txtCMSTN.Text = ""
				txtCMVAT.Text = ""
				cboCMVAT.defText = ""
				txtCMARB.Text = CStr(0)
				txtCMOEM.Text = CStr(0)
				txtCMAIA.Text = CStr(0)
				txtCMAPA.Text = CStr(0)
				txtCMYSA.Text = CStr(0)
				txtCMYPA.Text = CStr(0)
				txtCMDLP.Text = ""
				txtCMDLI.Text = ""
			Else
				RecRCM = DBconn.Execute("Select * from RCM where CMCNO='" & cboCMCNO.BoundText & "'")
				With RecRCM
					txtCMCNO.Text = .Fields("CMCNO").Value
					txtCMNME.Text = Find("RCM", "CMNME", " WHERE CMCNO='" & txtCMCNO.Text & "'")
					txtCMCTN.Text = IIf(IsDBNull(.Fields("CMCTN").Value), "", .Fields("CMCTN").Value)
					txtCMAD1.Text = IIf(IsDBNull(.Fields("CMAD1").Value), "", .Fields("CMAD1").Value)
					txtCMAD2.Text = IIf(IsDBNull(.Fields("CMAD2").Value), "", .Fields("CMAD2").Value)
					txtCMCIT.Text = IIf(IsDBNull(.Fields("CMCIT").Value), "", .Fields("CMCIT").Value)
					txtCMPSC.Text = IIf(IsDBNull(.Fields("CMPSC").Value), "", .Fields("CMPSC").Value)
					txtCMCNT.Text = IIf(IsDBNull(.Fields("CMCNT").Value), "", .Fields("CMCNT").Value)
					txtCMTEL.Text = IIf(IsDBNull(.Fields("CMTEL").Value), "", .Fields("CMTEL").Value)
					txtCMFAX.Text = IIf(IsDBNull(.Fields("CMFAX").Value), "", .Fields("CMFAX").Value)
					txtCMVID.Text = IIf(IsDBNull(.Fields("CMVID").Value), "", .Fields("CMVID").Value)
					txtCMCID.Text = IIf(IsDBNull(.Fields("CMCID").Value), "", .Fields("CMCID").Value)
					txtCNONM.Text = Find("ACN", "CNONM", " WHERE CNCID='" & txtCMCID.Text & "'")
					cboCMCID.defText = txtCNONM.Text
					txtCMGCD.Text = IIf(IsDBNull(.Fields("CMGCD").Value), "", .Fields("CMGCD").Value)
					txtCMSNO.Text = IIf(IsDBNull(.Fields("CMSNO").Value), "", .Fields("CMSNO").Value)
					txtMMNME.Text = Find("SMM", "MMNME", " WHERE MMSNO='" & txtCMSNO.Text & "'")
					cboCMSNO.defText = txtMMNME.Text
					txtCMCLM.Text = IIf(IsDBNull(.Fields("CMCLM").Value), 0, .Fields("CMCLM").Value)
					If IsDBNull(.Fields("CMCRS").Value) Then
						chkCMCRS.CheckState = System.Windows.Forms.CheckState.Unchecked
					Else
						chkCMCRS.CheckState = IIf(.Fields("CMCRS").Value, 1, 0)
					End If
					txtCMPTC.Text = IIf(IsDBNull(.Fields("CMPTC").Value), "", .Fields("CMPTC").Value)
					txtPTDSC.Text = Find("APT", "PTDSC", " WHERE PTPTC='" & txtCMPTC.Text & "'")
					txtCMTYP.Text = IIf(IsDBNull(.Fields("CMTYP").Value), "", .Fields("CMTYP").Value)
					txtCTDSC.Text = Find("RCT", "CTDSC", " WHERE CTTYP='" & txtCMTYP.Text & "'")
					txtCMSTN.Text = IIf(IsDBNull(.Fields("CMSTN").Value), "", .Fields("CMSTN").Value)
					txtCMVAT.Text = IIf(IsDBNull(.Fields("CMVAT").Value), "", .Fields("CMVAT").Value)
					cboCMVAT.defText = Find("VVT", "VTDSC", " WHERE VTVTP='" & txtCMVAT.Text & "'")
					txtCMARB.Text = IIf(IsDBNull(.Fields("CMARB").Value), 0, .Fields("CMARB").Value)
					txtCMOEM.Text = IIf(IsDBNull(.Fields("CMOEM").Value), 0, .Fields("CMOEM").Value)
					txtCMAIA.Text = IIf(IsDBNull(.Fields("CMAIA").Value), 0, .Fields("CMAIA").Value)
					txtCMAPA.Text = IIf(IsDBNull(.Fields("CMAPA").Value), 0, .Fields("CMAPA").Value)
					txtCMYSA.Text = IIf(IsDBNull(.Fields("CMYSA").Value), 0, .Fields("CMYSA").Value)
					txtCMYPA.Text = IIf(IsDBNull(.Fields("CMYPA").Value), 0, .Fields("CMYPA").Value)
					txtCMDLP.Text = IIf(IsDBNull(.Fields("CMDLP").Value), "", .Fields("CMDLP").Value)
					txtCMDLI.Text = IIf(IsDBNull(.Fields("CMDLI").Value), "", .Fields("CMDLI").Value)
				End With
			End If


		End Sub
		Sub WriteToFile()
			Dim SQL As Object
			On Error GoTo acr100_err
			If ISADDING Then
				SQL = "Insert into RCM(CMCNO,CMNME,CMCTN,CMAD1" & ",CMAD2,CMCIT,CMPSC,CMCNT" & ",CMTEL,CMFAX,CMVID,CMCID" & ",CMGCD,CMSNO,CMCLM,CMCRS" & ",CMPTC,CMSTN,CMVAT,CMTYP) values " & "('" & txtCMCNO.Text & "','" & txtCMNME.Text & "','" & txtCMCTN.Text & "','" & txtCMAD1.Text & "','" & txtCMAD2.Text & "','" & txtCMCIT.Text & "','" & txtCMPSC.Text & "','" & txtCMCNT.Text & "','" & txtCMTEL.Text & "','" & txtCMFAX.Text & "','" & txtCMVID.Text & "','" & txtCMCID.Text & "','" & txtCMGCD.Text & "','" & txtCMSNO.Text & "','" & txtCMCLM.Text & "','" & chkCMCRS.CheckState & "','" & txtCMPTC.Text & "','" & txtCMSTN.Text & "','" & txtCMVAT.Text & "','" & txtCMTYP.Text & "')"
			Else
				SQL = "UPDATE RCM SET CMCNO='" & txtCMCNO.Text & "',CMNME='" & txtCMNME.Text & "',CMCTN='" & txtCMCTN.Text & "',CMAD1='" & txtCMAD1.Text & "',CMAD2='" & txtCMAD2.Text & "',CMCIT='" & txtCMCIT.Text & "',CMPSC='" & txtCMPSC.Text & "',CMCNT='" & txtCMCNT.Text & "',CMTEL='" & txtCMTEL.Text & "',CMFAX='" & txtCMFAX.Text & "',CMVID='" & txtCMVID.Text & "',CMCID='" & txtCMCID.Text & "',CMGCD='" & txtCMGCD.Text & "',CMSNO='" & txtCMSNO.Text & "',CMCLM='" & txtCMCLM.Text & "',CMCRS='" & chkCMCRS.CheckState & "',CMPTC='" & txtCMPTC.Text & "',CMSTN='" & txtCMSTN.Text & "',CMVAT='" & txtCMVAT.Text & "',CMTYP='" & txtCMTYP.Text & "'" & " WHERE CMCNO='" & cboCMCNO.BoundText & "'"
			End If
			DBconn.Execute(SQL)
			Adodc1.RecordSource = "Select * from RCM"
			Adodc1.Refresh()
			cboCMCNO.BoundText = txtCMCNO.Text
acr100_next:
			Exit Sub
acr100_err:
			MsgBox(Err.Description)
			GoTo acr100_next
		End Sub

		Private Sub frmACR100_Activated(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Activated
			OpenFile()
			ButtonStatus()
			VB6_AddADODataBinding()
			cboCMCNO.RowSource = ADOBind_Adodc1.DataSource
			cboCMCID.RowSource = ADOBind_Adodc2.DataSource
			cboCMTYP.RowSource = ADOBind_Adodc6.DataSource
			cboCMVAT.RowSource = ADOBind_Adodc4.DataSource
			cboCMPTC.RowSource = ADOBind_Adodc5.DataSource
			cboCMSNO.RowSource = ADOBind_Adodc3.DataSource
		End Sub

		Private Sub txtCMAD1_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMAD1.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then txtCMAD2.Focus()
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMAD2_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMAD2.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then txtCMCNT.Focus()
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMCID_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMCID.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			Dim Result As String
			If KeyAscii = 13 Then

				Result = Find("ACN", "CNONM", " WHERE CNCID='" & txtCMCID.Text & "'")
				If Result = "" Then
					cboCMCID.Visible = True
					cboCMCID.Focus()
				Else
					txtCNONM.Text = Result
					cboCMCID.Visible = False
					txtCMTYP.Focus()
				End If

			End If
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMCIT_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMCIT.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then txtCMPSC.Focus()
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMCLM_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMCLM.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then chkCMCRS.Focus()
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMCNO_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMCNO.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then
				If ValidMaso(OldCMCNO, txtCMCNO, "RCM", " CMCNO='" & txtCMCNO.Text & "'") Then
					MsgBox("This code is already exist")
					txtCMCNO.Focus()
				Else
					txtCMCID.Focus()
				End If

			End If
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMCNT_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMCNT.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then txtCMCIT.Focus()
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMCTN_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMCTN.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then txtCMAD1.Focus()
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMFAX_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMFAX.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then txtCMVID.Focus()
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMGCD_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMGCD.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then txtCMVAT.Focus()
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMNME_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMNME.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then txtCMCTN.Focus()
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMPSC_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMPSC.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then txtCMTEL.Focus()
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMPTC_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMPTC.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			Dim Result As String
			If KeyAscii = 13 Then
				Result = Find("APT", "PTDSC", " WHERE PTPTC='" & txtCMPTC.Text & "'")
				If Result <> "" Then
					txtPTDSC.Text = Result
					txtCMSTN.Focus()
				Else
					cboCMPTC.Visible = True
					cboCMPTC.Focus()
				End If

			End If
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMSNO_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMSNO.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			Dim Result As String
			If KeyAscii = 13 Then
				Result = Find("SMM", "MMNME", " WHERE MMSNO='" & txtCMSNO.Text & "'")
				If Result = "" Then
					cboCMSNO.Visible = True
					cboCMSNO.Focus()
				Else
					txtMMNME.Text = Result
					cboCMSNO.Visible = False
					'txtCMNME.SetFocus
				End If
			End If
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMSTN_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMSTN.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then txtCMSNO.Focus()
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMTEL_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMTEL.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then txtCMFAX.Focus()
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMTYP_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMTYP.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			Dim Result As Object
			If KeyAscii = 13 Then
				Result = Find("RCT", "CTDSC", " WHERE CTTYP='" & txtCMTYP.Text & "'")
				If Result <> "" Then
					txtCTDSC.Text = Result
					txtCMNME.Focus()
				Else
					cboCMTYP.Visible = True
					cboCMTYP.Focus()
				End If

			End If
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMVAT_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMVAT.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			Dim Result As String
			If KeyAscii = 13 Then

				Result = Find("VVT", "VTDSC", " WHERE VTVTP='" & txtCMVAT.Text & "'")
				If Result = "" Then
					cboCMVAT.Visible = True
					cboCMVAT.Focus()
				Else
					txtVTDSC.Text = Result
					cboCMVAT.Visible = False
					txtCMCLM.Focus()
				End If
			End If
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub

		Private Sub txtCMVID_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtCMVID.KeyPress
			Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
			If KeyAscii = 13 Then txtCMGCD.Focus()
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		End Sub
		Sub OpenFile()
			Dim SQL As Object
			Adodc1.ConnectionString = ConnectString
			Adodc1.ConnectionTimeout = 10
			Adodc1.CommandType = ADODB.CommandTypeEnum.adCmdText
			Adodc1.RecordSource = "Select * from RCM ORDER BY CMNME"
			Adodc1.Refresh()

			Adodc2.ConnectionString = ConnectString
			Adodc2.ConnectionTimeout = 10
			Adodc2.CommandType = ADODB.CommandTypeEnum.adCmdText
			Adodc2.RecordSource = "Select * from ACN"
			Adodc2.Refresh()

			'FieldDel = "IMRID"
			'DelStatus = "IZ"
			SQL = "Select * from SMM " 'where " & FieldDel & " <>'" & DelStatus & "' "
			Adodc3.ConnectionString = ConnectString
			Adodc3.ConnectionTimeout = 10
			Adodc3.CommandType = ADODB.CommandTypeEnum.adCmdText
			Adodc3.RecordSource = SQL
			Adodc3.Refresh()

			Adodc4.ConnectionString = ConnectString
			Adodc4.ConnectionTimeout = 10
			Adodc4.CommandType = ADODB.CommandTypeEnum.adCmdText
			Adodc4.RecordSource = "Select * From VVT"
			Adodc4.Refresh()

			Adodc5.ConnectionString = ConnectString
			Adodc5.ConnectionTimeout = 10
			Adodc5.CommandType = ADODB.CommandTypeEnum.adCmdText
			Adodc5.RecordSource = "Select * From APT"
			Adodc5.Refresh()

			Adodc6.ConnectionString = ConnectString
			Adodc6.ConnectionTimeout = 10
			Adodc6.CommandType = ADODB.CommandTypeEnum.adCmdText
			Adodc6.RecordSource = "Select * From RCT"
			Adodc6.Refresh()
		End Sub
	End Class
End Namespace